home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / ear / mui23dev.lha / MUI / Developer / C / Examples / MUI-Demo.c < prev    next >
C/C++ Source or Header  |  1994-12-23  |  28KB  |  655 lines

  1. /*
  2. **          C Source Code For The MUI Demo Program
  3. **          --------------------------------------
  4. **
  5. **             written 1992-94 by Stefan Stuntz
  6. **
  7. ** Even if it doesn't look so, all of the code below is pure C,
  8. ** just a little bit enhanced with some MUI specific macros.
  9. */
  10.  
  11. #include "demo.h"
  12.  
  13.  
  14. /*
  15. ** A little array definition:
  16. */
  17.  
  18. static const char *LVT_Brian[] =
  19. {
  20. "Cheer up, Brian. You know what they say.",
  21. "Some things in life are bad,",
  22. "They can really make you mad.",
  23. "Other things just make you swear and curse.",
  24. "When you're chewing on life's grissle,",
  25. "Don't grumble, give a whistle.",
  26. "And this'll help things turn out for the best,",
  27. "And...",
  28. "",
  29. "Always look on the bright side of life",
  30. "Always look on the light side of life",
  31. "",
  32. "If life seems jolly rotten,",
  33. "There's something you've forgotten,",
  34. "And that's to laugh, and smile, and dance, and sing.",
  35. "When you're feeling in the dumps,",
  36. "Don't be silly chumps,",
  37. "Just purse your lips and whistle, that's the thing.",
  38. "And...",
  39. "",
  40. "Always look on the bright side of life, come on!",
  41. "Always look on the right side of life",
  42. "",
  43. "For life is quite absurd,",
  44. "And death's the final word.",
  45. "You must always face the curtain with a bow.",
  46. "Forget about your sin,",
  47. "Give the audience a grin.",
  48. "Enjoy it, it's your last chance anyhow,",
  49. "So...",
  50. "",
  51. "Always look on the bright side of death",
  52. "Just before you draw your terminal breath.",
  53. "",
  54. "Life's a piece of shit,",
  55. "When you look at it.",
  56. "Life's a laugh, and death's a joke, it's true.",
  57. "You'll see it's all a show,",
  58. "Keep 'em laughing as you go,",
  59. "Just remember that the last laugh is on you.",
  60. "And...",
  61. "",
  62. "Always look on the bright side of life !",
  63. "",
  64. "...",
  65. "",
  66. "[Thanx to sprooney@unix1.tcd.ie and to M. Python]",
  67. NULL,
  68. };
  69.  
  70.  
  71.  
  72. /*
  73. ** Convetional GadTools NewMenu structure, a memory
  74. ** saving way of definig menus.
  75. */
  76.  
  77. #define ID_ABOUT  1
  78. #define ID_NEWVOL 2
  79. #define ID_NEWBRI 3
  80.  
  81. struct NewMenu Menu[] =
  82. {
  83.     { NM_TITLE, "Project"  , 0 ,0,0,(APTR)0            },
  84.     { NM_ITEM , "About..." ,"?",0,0,(APTR)ID_ABOUT     },
  85.     { NM_ITEM , NM_BARLABEL, 0 ,0,0,(APTR)0            },
  86.     { NM_ITEM , "Quit"     ,"Q",0,0,(APTR)MUIV_Application_ReturnID_Quit },
  87.     { NM_END  , NULL       , 0 ,0,0,(APTR)0            },
  88. };
  89.  
  90.  
  91. /*
  92. ** Here are all the little info texts
  93. ** that appear at the top of each demo window.
  94. */
  95.  
  96. static const char IN_Master[]    = "\tWelcome to the MUI demonstration program. \
  97. This little toy will show you how easy it is to create graphical user interfaces \
  98. with MUI and how powerful the results are.\n\tMUI is based on BOOPSI, Amiga's \
  99. basic object oriented programming system. For details about programming, see the \
  100. 'ReadMe' file and the documented source code of this demo. Only one thing so far: \
  101. it's really easy!\n\tNow go on, click around and watch this demo. Or use your \
  102. keyboard (TAB, Return, Cursor-Keys) if you like that better. Hint: play \
  103. around with the MUI preferences program and customize every pixel to fit \
  104. your personal taste.";
  105.  
  106. static const char IN_Notify[]    = "\tMUI objects communicate with each other \
  107. with the aid of a notifcation system. This system is frequently used in every \
  108. MUI application. Binding an up and a down arrow to a prop gadget e.g. makes up \
  109. a scrollbar, binding a scrollbar to a list makes up a listview. You can also \
  110. bind windows to buttons, thus the window will be opened when the button is \
  111. pressed.\n\tRemember: The main loop of this demo program simply consists of \
  112. a Wait(). Once set up, MUI handles all user actions concerning the GUI \
  113. automatically.";
  114.  
  115. static const char IN_Frames[]    = "\tEvery MUI object can have a surrounding \
  116. frame. Several types are available, all adjustable with the preferences program.";
  117.  
  118. static const char IN_Images[]    = "\tMUI offers a vector image class, that allows \
  119. images to be zoomed to any dimension. Every MUI image is transformed to match the \
  120. current screens colors before displaying.\n\tThere are several standard images for \
  121. often used GUI components (e.g. Arrows). These standard images can be defined via \
  122. the preferences program.";
  123.  
  124. static const char IN_Groups[]    = "\tGroups are very important for MUI. Their \
  125. combinations determine how the GUI will look. A group may contain any number of \
  126. child objects, which are positioned either horizontal or vertical.\n\tWhen a \
  127. group is layouted, the available space is distributed between all of its \
  128. children, depending on their minimum and maximum dimensions and on their \
  129. weight.\n\tOf course, the children of a group may be other groups. There \
  130. are no restrictions.";
  131.  
  132. static const char IN_Backfill[]  = "\tEvery object can have its own background, \
  133. if it wants to. MUI offers several standard backgrounds (e.g. one of the DrawInfo \
  134. pens or one of the rasters below).\nThe prefs program allows defining a large number \
  135. of backgrounds... try it!";
  136.  
  137. static const char IN_Listviews[] = "\tMUI's list class is very flexible. A list can \
  138. be made up of any number of columns containing formatted text or even images. Several \
  139. subclasses of list class (e.g. a directory class and a volume class) are available. \
  140. All MUI lists have the capability of multi selection, just by setting a single \
  141. flag.\n\tThe small info texts at the top of each demo window are made with floattext \
  142. class. This one just needs a character string as input and formats the text according \
  143. to its width.";
  144.  
  145. static const char IN_Cycle[]     = "\tCycle gadgets, radios buttons and simple lists \
  146. can be used to let the user pick exactly one selection from a list of choices. In this \
  147. example, all three possibilities are shown. Of course they are connected via notification, \
  148. so every object will immediately be notified and updated when necessary.";
  149.  
  150. static const char IN_String[]    = "\tOf course, MUI offers a standard string gadget class \
  151. for text input. The gadget in this example is attached to the list, you can control the \
  152. list cursor from within the gadget.";
  153.  
  154.  
  155. /*
  156. ** This are the entries for the cycle gadgets and radio buttons.
  157. */
  158.  
  159. static const char *CYA_Computer[] = { "Amiga 500","Amiga 600","Amiga 1000 :)","Amiga 1200","Amiga 2000","Amiga 3000","Amiga 4000", "Amiga 4000T", "Atari ST :(", NULL };
  160. static const char *CYA_Printer[]  = { "HP Deskjet","NEC P6","Okimate 20",NULL };
  161. static const char *CYA_Display[]  = { "A1081","NEC 3D","A2024","Eizo T660i",NULL };
  162.  
  163.  
  164. /*
  165. ** Some Macros to make my life easier and the actual source
  166. ** code more readable.
  167. */
  168.  
  169. #define List(ftxt)               ListviewObject, MUIA_Weight, 50, MUIA_Listview_Input, FALSE, MUIA_Listview_List,\
  170.                                  FloattextObject, MUIA_Frame, MUIV_Frame_ReadList, MUIA_Floattext_Text, ftxt, MUIA_Floattext_TabSize, 4, MUIA_Floattext_Justify, TRUE, End, End
  171. #define DemoWindow(name,id,info) WindowObject, MUIA_Window_Title, name, MUIA_Window_ID, id, WindowContents, VGroup, Child, List(info)
  172. #define Image(nr)                ImageObject, MUIA_Image_Spec, nr, End
  173. #define ScaledImage(nr,s,x,y)    ImageObject, MUIA_Image_Spec, nr, MUIA_FixWidth, x, MUIA_FixHeight, y, MUIA_Image_FreeHoriz, TRUE, MUIA_Image_FreeVert, TRUE, MUIA_Image_State, s, End
  174. #define HProp                    PropObject, PropFrame, MUIA_Prop_Horiz, TRUE, MUIA_FixHeight, 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  175. #define VProp                    PropObject, PropFrame, MUIA_Prop_Horiz, FALSE, MUIA_FixWidth , 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  176.  
  177.  
  178. /*
  179. ** For every object we want to refer later (e.g. for notification purposes)
  180. ** we need a pointer. These pointers do not need to be static, but this
  181. ** saves stack space.
  182. */
  183.  
  184. static APTR AP_Demo;
  185. static APTR WI_Master,WI_Frames,WI_Images,WI_Notify,WI_Listviews,WI_Groups,WI_Backfill,WI_Cycle,WI_String;
  186. static APTR BT_Notify,BT_Frames,BT_Images,BT_Groups,BT_Backfill,BT_Listviews,BT_Cycle,BT_String,BT_Quit;
  187. static APTR PR_PropA,PR_PropH,PR_PropV,PR_PropL,PR_PropR,PR_PropT,PR_PropB;
  188. static APTR LV_Volumes,LV_Directory,LV_Computer,LV_Brian;
  189. static APTR CY_Computer,CY_Printer,CY_Display;
  190. static APTR MT_Computer,MT_Printer,MT_Display;
  191. static APTR ST_Brian;
  192. static APTR GA_Gauge1,GA_Gauge2,GA_Gauge3;
  193. static APTR BP_Wheel;
  194.  
  195.  
  196. /*
  197. ** This is where it all begins...
  198. */
  199.  
  200. int main(int argc,char *argv[])
  201. {
  202.  
  203. /*
  204. ** The init() functions is define in demos.h and does nothing
  205. ** but open "muimaster.library".
  206. */
  207.  
  208.     init();
  209.  
  210.  
  211. /*
  212. ** Every MUI application needs an application object
  213. ** which will hold general information and serve as
  214. ** a kind of anchor for user input, ARexx functions,
  215. ** commodities interface, etc.
  216. **
  217. ** An application may have any number of SubWindows
  218. ** which can all be created in the same call or added
  219. ** later, according to your needs.
  220. **
  221. ** Note that creating a window does not mean to
  222. ** open it, this will be done later by setting
  223. ** the windows open attribute.
  224. */
  225.  
  226.     AP_Demo = ApplicationObject,
  227.         MUIA_Application_Title         , "MUI-Demo",
  228.         MUIA_Application_Version       , "$VER: MUI-Demo 10.11 (23.12.94)",
  229.         MUIA_Application_Copyright     , "Copyright ©1992-94, Stefan Stuntz",
  230.         MUIA_Application_Author        , "Stefan Stuntz",
  231.         MUIA_Application_Description   , "Demonstrate the features of MUI.",
  232.         MUIA_Application_Base          , "MUIDEMO",
  233.         MUIA_Application_Menustrip     , MUI_MakeObject(MUIO_MenustripNM,Menu,0),
  234.  
  235.         SubWindow,
  236.             WI_String = DemoWindow("String",MAKE_ID('S','T','R','G'),IN_String),
  237.                 Child, LV_Brian = ListviewObject,
  238.                     MUIA_Listview_Input, TRUE,
  239.                     MUIA_Listview_List, ListObject, InputListFrame, End,
  240.                     End,
  241.                 Child, ST_Brian = StringObject, StringFrame, End,
  242.                 End,
  243.             End,
  244.  
  245.         SubWindow,
  246.             WI_Cycle = DemoWindow("Cycle Gadgets & RadioButtons",MAKE_ID('C','Y','C','L'),IN_Cycle),
  247.                 Child, HGroup,
  248.                     Child, MT_Computer = Radio("Computer:",CYA_Computer),
  249.                     Child, VGroup,
  250.                         Child, MT_Printer = Radio("Printer:",CYA_Printer),
  251.                         Child, VSpace(0),
  252.                         Child, MT_Display = Radio("Display:",CYA_Display),
  253.                         End,
  254.                     Child, VGroup,
  255.                         Child, ColGroup(2), GroupFrameT("Cycle Gadgets"),
  256.                             Child, KeyLabel1("Computer:",'c'), Child, CY_Computer = KeyCycle(CYA_Computer,'c'),
  257.                             Child, KeyLabel1("Printer:" ,'p'), Child, CY_Printer  = KeyCycle(CYA_Printer ,'p'),
  258.                             Child, KeyLabel1("Display:" ,'d'), Child, CY_Display  = KeyCycle(CYA_Display ,'d'),
  259.                             End,
  260.                         Child, LV_Computer =    ListviewObject,
  261.                             MUIA_Listview_Input, TRUE,
  262.                             MUIA_Listview_List, ListObject, InputListFrame, End,
  263.                             End,
  264.                         End,
  265.                     End,
  266.                 End,
  267.             End,
  268.  
  269.         SubWindow,
  270.             WI_Listviews = DemoWindow("Listviews",MAKE_ID('L','I','S','T'),IN_Listviews),
  271.                 Child, HGroup, GroupFrameT("Dir & Volume List"),
  272.                     Child, LV_Directory = ListviewObject,
  273.                         MUIA_Listview_Input, TRUE,
  274.                         MUIA_Listview_MultiSelect, TRUE,
  275.                         MUIA_Listview_List, DirlistObject, InputListFrame, MUIA_Dirlist_Directory, "ram:", MUIA_List_Title, TRUE, End,
  276.                         End,
  277.                     Child, LV_Volumes = ListviewObject,
  278.                         MUIA_Weight, 20,
  279.                         MUIA_Listview_Input, TRUE,
  280.                         MUIA_Listview_List, VolumelistObject, InputListFrame, MUIA_Dirlist_Directory, "ram:", End,
  281.                         End,
  282.                     End,
  283.                 End,
  284.             End,
  285.  
  286.         SubWindow,
  287.             WI_Notify = DemoWindow("Notifying",MAKE_ID('B','R','C','A'),IN_Notify),
  288.                 Child, HGroup, GroupFrameT("Connections"),
  289.                     Child, GA_Gauge1 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, FALSE, MUIA_FixWidth, 16, End,
  290.                     Child, PR_PropL = VProp,
  291.                     Child, PR_PropR = VProp,
  292.                     Child, VGroup,
  293.                         Child, VSpace(0),
  294.                         Child, PR_PropA = HProp,
  295.                         Child, HGroup,
  296.                             Child, PR_PropH = HProp,
  297.                             Child, PR_PropV = HProp,
  298.                             End,
  299.                         Child, VSpace(0),
  300.                         Child, VGroup, GroupSpacing(1),
  301.                             Child, GA_Gauge2 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, TRUE, End,
  302.                             Child, ScaleObject, MUIA_Scale_Horiz, TRUE, End,
  303.                             End,
  304.                         Child, VSpace(0),
  305.                         End,
  306.                     Child, PR_PropT = VProp,
  307.                     Child, PR_PropB = VProp,
  308.                     Child, GA_Gauge3 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, FALSE, MUIA_FixWidth, 16, End,
  309.                     End,
  310.                 End,
  311.             End,
  312.  
  313.         SubWindow,
  314.             WI_Backfill = DemoWindow("Backfill",MAKE_ID('B','A','C','K'),IN_Backfill),
  315.                 Child, VGroup, GroupFrameT("Standard Backgrounds"),
  316.                     Child, HGroup,
  317.                         Child, RectangleObject, TextFrame, MUIA_Background, MUII_BACKGROUND            , End,
  318.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILL                  , End,
  319.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOW                , End,
  320.                         End,
  321.                     Child, HGroup,
  322.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWBACK            , End,
  323.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWFILL            , End,
  324.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWSHINE           , End,
  325.                         End,
  326.                     Child, HGroup,
  327.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILLBACK              , End,
  328.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHINEBACK             , End,
  329.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILLSHINE             , End,
  330.                         End,
  331.                     End,
  332.                 End,
  333.             End,
  334.  
  335.         SubWindow,
  336.             WI_Groups = DemoWindow("Groups",MAKE_ID('G','R','P','S'),IN_Groups),
  337.                 Child, HGroup, GroupFrameT("Group Types"),
  338.                     Child, HGroup, GroupFrameT("Horizontal"),
  339.                         Child, RectangleObject, TextFrame, End,
  340.                         Child, RectangleObject, TextFrame, End,
  341.                         Child, RectangleObject, TextFrame, End,
  342.                         End,
  343.                     Child, VGroup, GroupFrameT("Vertical"),
  344.                         Child, RectangleObject, TextFrame, End,
  345.                         Child, RectangleObject, TextFrame, End,
  346.                         Child, RectangleObject, TextFrame, End,
  347.                         End,
  348.                     Child, ColGroup(3), GroupFrameT("Array"),
  349.                         Child, RectangleObject, TextFrame, End,
  350.                         Child, RectangleObject, TextFrame, End,
  351.                         Child, RectangleObject, TextFrame, End,
  352.                         Child, RectangleObject, TextFrame, End,
  353.                         Child, RectangleObject, TextFrame, End,
  354.                         Child, RectangleObject, TextFrame, End,
  355.                         Child, RectangleObject, TextFrame, End,
  356.                         Child, RectangleObject, TextFrame, End,
  357.                         Child, RectangleObject, TextFrame, End,
  358.                         End,
  359.                     End,
  360.                 Child, HGroup, GroupFrameT("Different Weights"),
  361.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c25 kg" ,  MUIA_Weight,  25, End,
  362.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c50 kg" ,  MUIA_Weight,  50, End,
  363.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c75 kg" ,  MUIA_Weight,  75, End,
  364.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c100 kg",  MUIA_Weight, 100, End,
  365.                     End,
  366.                 Child, HGroup, GroupFrameT("Fixed & Variable Sizes"),
  367.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  368.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cfree"  ,  MUIA_Text_SetMax, FALSE, End,
  369.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  370.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cfree"  ,  MUIA_Text_SetMax, FALSE, End,
  371.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  372.                     End,
  373.                 End,
  374.             End,
  375.  
  376.         SubWindow,
  377.             WI_Frames = DemoWindow("Frames",MAKE_ID('F','R','M','S'),IN_Frames),
  378.                 Child, ColGroup(2),
  379.                     Child, TextObject, ButtonFrame     , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cButton"     , End,
  380.                     Child, TextObject, ImageButtonFrame, InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cImageButton", End,
  381.                     Child, TextObject, TextFrame       , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cText"       , End,
  382.                     Child, TextObject, StringFrame     , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cString"     , End,
  383.                     Child, TextObject, ReadListFrame   , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cReadList"   , End,
  384.                     Child, TextObject, InputListFrame  , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cInputList"  , End,
  385.                     Child, TextObject, PropFrame       , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cProp Gadget", End,
  386.                     Child, TextObject, GroupFrame      , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cGroup"      , End,
  387.                     End,
  388.                 End,
  389.             End,
  390.  
  391.         SubWindow,
  392.             WI_Images = DemoWindow("Images",MAKE_ID('I','M','G','S'),IN_Images),
  393.                 Child, HGroup,
  394.                     Child, ColGroup(2), GroupFrameT("Some Images"),
  395.                         Child, Label("ArrowUp:"    ), Child, Image(MUII_ArrowUp    ),
  396.                         Child, Label("ArrowDown:"  ), Child, Image(MUII_ArrowDown  ),
  397.                         Child, Label("ArrowLeft:"  ), Child, Image(MUII_ArrowLeft  ),
  398.                         Child, Label("ArrowRight:" ), Child, Image(MUII_ArrowRight ),
  399.                         Child, Label("RadioButton:"), Child, Image(MUII_RadioButton),
  400.                         Child, Label("File:"       ), Child, Image(MUII_PopFile    ),
  401.                         Child, Label("HardDisk:"   ), Child, Image(MUII_HardDisk   ),
  402.                         Child, Label("Disk:"       ), Child, Image(MUII_Disk       ),
  403.                         Child, Label("Chip:"       ), Child, Image(MUII_Chip       ),
  404.                         Child, Label("Drawer:"     ), Child, Image(MUII_Drawer     ),
  405.                         End,
  406.                     Child, VGroup, GroupFrameT("Scale Engine"),
  407.                         Child, VSpace(0),
  408.                         Child, HGroup,
  409.                             Child, ScaledImage(MUII_RadioButton,1,17, 9),
  410.                             Child, ScaledImage(MUII_RadioButton,1,20,12),
  411.                             Child, ScaledImage(MUII_RadioButton,1,23,15),
  412.                             Child, ScaledImage(MUII_RadioButton,1,26,18),
  413.                             Child, ScaledImage(MUII_RadioButton,1,29,21),
  414.                             End,
  415.                         Child, VSpace(0),
  416.                         Child, HGroup,
  417.                             Child, ScaledImage(MUII_CheckMark,1,13, 7),
  418.                             Child, ScaledImage(MUII_CheckMark,1,16,10),
  419.                             Child, ScaledImage(MUII_CheckMark,1,19,13),
  420.                             Child, ScaledImage(MUII_CheckMark,1,22,16),
  421.                             Child, ScaledImage(MUII_CheckMark,1,25,19),
  422.                             Child, ScaledImage(MUII_CheckMark,1,28,22),
  423.                             End,
  424.                         Child, VSpace(0),
  425.                         Child, HGroup,
  426.                             Child, ScaledImage(MUII_PopFile,0,12,10),
  427.                             Child, ScaledImage(MUII_PopFile,0,15,13),
  428.                             Child, ScaledImage(MUII_PopFile,0,18,16),
  429.                             Child, ScaledImage(MUII_PopFile,0,21,19),
  430.                             Child, ScaledImage(MUII_PopFile,0,24,22),
  431.                             Child, ScaledImage(MUII_PopFile,0,27,25),
  432.                             End,
  433.                         Child, VSpace(0),
  434.                         End,
  435.                     End,
  436.                 End,
  437.             End,
  438.  
  439.         SubWindow,
  440.             WI_Master = WindowObject,
  441.             MUIA_Window_Title, "MUI-Demo",
  442.             MUIA_Window_ID   , MAKE_ID('M','A','I','N'),
  443.             WindowContents, VGroup,
  444.                 Child, TextObject, GroupFrame, MUIA_Background, MUII_SHADOWFILL, MUIA_Text_Contents, "\33c\0338MUI - \33bM\33nagic\33bU\33nser\33bI\33nnterface\nwritten 1992-94 by Stefan Stuntz",  End,
  445.  
  446.                 Child, List(IN_Master),
  447.  
  448.                 Child, VGroup, GroupFrameT("Available Demos"),
  449.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  450.                         Child, BT_Groups    = SimpleButton("_Groups"),
  451.                         Child, BT_Frames    = SimpleButton("_Frames"),
  452.                         Child, BT_Backfill  = SimpleButton("_Backfill"),
  453.                         End,
  454.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  455.                         Child, BT_Notify    = SimpleButton("_Notify"),
  456.                         Child, BT_Listviews = SimpleButton("_Listviews"),
  457.                         Child, BT_Cycle     = SimpleButton("_Cycle"),
  458.                         End,
  459.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  460.                         Child, BT_Images    = SimpleButton("_Images" ),
  461.                         Child, BT_String    = SimpleButton("_Strings"),
  462.                         Child, BT_Quit      = SimpleButton("_Quit"   ),
  463.                         End,
  464.                     End,
  465.                 End,
  466.             End,
  467.  
  468.         End;
  469.  
  470.  
  471. /*
  472. ** See if the application was created. The fail function
  473. ** is defined in demos.h, it deletes every created object
  474. ** and closes "muimaster.library".
  475. **
  476. ** Note that we do not need any
  477. ** error control for the sub objects since every error
  478. ** will automatically be forwarded to the parent object
  479. ** and cause this one to fail too.
  480. */
  481.  
  482.     if (!AP_Demo) fail(AP_Demo,"Failed to create application.");
  483.  
  484.  
  485.  
  486. /*
  487. ** Here comes the notifcation magic. Notifying means:
  488. ** When an attribute of an object changes, then please change
  489. ** another attribute of another object (accordingly) or send
  490. ** a method to another object.
  491. */
  492.  
  493. /*
  494. ** Lets bind the sub windows to the corresponding button
  495. ** of the master window.
  496. */
  497.  
  498.     DoMethod(BT_Frames   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Frames   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  499.     DoMethod(BT_Images   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Images   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  500.     DoMethod(BT_Notify   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Notify   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  501.     DoMethod(BT_Listviews,MUIM_Notify,MUIA_Pressed,FALSE,WI_Listviews,3,MUIM_Set,MUIA_Window_Open,TRUE);
  502.     DoMethod(BT_Groups   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Groups   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  503.     DoMethod(BT_Backfill ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Backfill ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  504.     DoMethod(BT_Cycle    ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Cycle    ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  505.     DoMethod(BT_String   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_String   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  506.  
  507.     DoMethod(BT_Quit     ,MUIM_Notify,MUIA_Pressed,FALSE,AP_Demo,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  508.  
  509.  
  510. /*
  511. ** Automagically remove a window when the user hits the close gadget.
  512. */
  513.  
  514.     DoMethod(WI_Images   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Images   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  515.     DoMethod(WI_Frames   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Frames   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  516.     DoMethod(WI_Notify   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Notify   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  517.     DoMethod(WI_Listviews,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Listviews,3,MUIM_Set,MUIA_Window_Open,FALSE);
  518.     DoMethod(WI_Groups   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Groups   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  519.     DoMethod(WI_Backfill ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Backfill ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  520.     DoMethod(WI_Cycle    ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Cycle    ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  521.     DoMethod(WI_String   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_String   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  522.  
  523.  
  524. /*
  525. ** Closing the master window forces a complete shutdown of the application.
  526. */
  527.  
  528.     DoMethod(WI_Master,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,AP_Demo,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  529.  
  530.  
  531. /*
  532. ** This connects the prop gadgets in the notification demo window.
  533. */
  534.  
  535.     DoMethod(PR_PropA,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropH,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  536.     DoMethod(PR_PropA,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropV,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  537.     DoMethod(PR_PropH,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropL,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  538.     DoMethod(PR_PropH,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropR,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  539.     DoMethod(PR_PropV,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropT,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  540.     DoMethod(PR_PropV,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropB,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  541.  
  542.     DoMethod(PR_PropA ,MUIM_Notify,MUIA_Prop_First   ,MUIV_EveryTime,GA_Gauge2,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  543.     DoMethod(GA_Gauge2,MUIM_Notify,MUIA_Gauge_Current,MUIV_EveryTime,GA_Gauge1,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  544.     DoMethod(GA_Gauge2,MUIM_Notify,MUIA_Gauge_Current,MUIV_EveryTime,GA_Gauge3,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  545.  
  546.  
  547. /*
  548. ** And here we connect cycle gadgets, radio buttons and the list in the
  549. ** cycle & radio window.
  550. */
  551.  
  552.     DoMethod(CY_Computer,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Computer,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  553.     DoMethod(CY_Printer ,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Printer ,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  554.     DoMethod(CY_Display ,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Display ,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  555.     DoMethod(MT_Computer,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Computer,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  556.     DoMethod(MT_Printer ,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Printer ,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  557.     DoMethod(MT_Display ,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Display ,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  558.     DoMethod(MT_Computer,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,LV_Computer,3,MUIM_Set,MUIA_List_Active ,MUIV_TriggerValue);
  559.     DoMethod(LV_Computer,MUIM_Notify,MUIA_List_Active ,MUIV_EveryTime,MT_Computer,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  560.  
  561.  
  562. /*
  563. ** This one makes us receive input ids from several list views.
  564. */
  565.  
  566.     DoMethod(LV_Volumes ,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,AP_Demo,2,MUIM_Application_ReturnID,ID_NEWVOL);
  567.     DoMethod(LV_Brian   ,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,AP_Demo,2,MUIM_Application_ReturnID,ID_NEWBRI);
  568.  
  569.  
  570. /*
  571. ** Now lets set the TAB cycle chain for some of our windows.
  572. */
  573.  
  574.     DoMethod(WI_Master   ,MUIM_Window_SetCycleChain,BT_Groups,BT_Frames,BT_Backfill,BT_Notify,BT_Listviews,BT_Cycle,BT_Images,BT_String,NULL);
  575.     DoMethod(WI_Listviews,MUIM_Window_SetCycleChain,LV_Directory,LV_Volumes,NULL);
  576.     DoMethod(WI_Cycle    ,MUIM_Window_SetCycleChain,MT_Computer,MT_Printer,MT_Display,CY_Computer,CY_Printer,CY_Display,LV_Computer,NULL);
  577.     DoMethod(WI_String   ,MUIM_Window_SetCycleChain,ST_Brian,NULL);
  578.  
  579.  
  580. /*
  581. ** Set some start values for certain objects.
  582. */
  583.  
  584.     DoMethod(LV_Computer,MUIM_List_Insert,CYA_Computer,-1,MUIV_List_Insert_Bottom);
  585.     DoMethod(LV_Brian   ,MUIM_List_Insert,LVT_Brian,-1,MUIV_List_Insert_Bottom);
  586.     set(LV_Computer,MUIA_List_Active,0);
  587.     set(LV_Brian   ,MUIA_List_Active,0);
  588.     set(ST_Brian   ,MUIA_String_AttachedList,LV_Brian);
  589.  
  590.  
  591. /*
  592. ** Everything's ready, lets launch the application. We will
  593. ** open the master window now.
  594. */
  595.  
  596.     set(WI_Master,MUIA_Window_Open,TRUE);
  597.  
  598.  
  599. /*
  600. ** This is the main loop. As you can see, it does just nothing.
  601. ** Everything is handled by MUI, no work for the programmer.
  602. **
  603. ** The only thing we do here is to react on a double click
  604. ** in the volume list (which causes an ID_NEWVOL) by setting
  605. ** a new directory name for the directory list. If you want
  606. ** to see a real file requester with MUI, wait for the
  607. ** next release of MFR :-)
  608. */
  609.  
  610.     {
  611.         ULONG signal;
  612.         BOOL running = TRUE;
  613.         char *buf;
  614.  
  615.         while (running)
  616.         {
  617.             switch (DoMethod(AP_Demo,MUIM_Application_Input,&signal))
  618.             {
  619.                 case MUIV_Application_ReturnID_Quit:
  620.                     running = FALSE;
  621.                     break;
  622.  
  623.                 case ID_NEWVOL:
  624.                     DoMethod(LV_Volumes,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&buf);
  625.                     set(LV_Directory,MUIA_Dirlist_Directory,buf);
  626.                     break;
  627.  
  628.                 case ID_NEWBRI:
  629.                     get(LV_Brian,MUIA_List_Active,&buf);
  630.                     set(ST_Brian,MUIA_String_Contents,LVT_Brian[(int)buf]);
  631.                     break;
  632.  
  633.                 case ID_ABOUT:
  634.                     MUI_Request(AP_Demo, WI_Master, 0, NULL, "OK", "MUI-Demo\n© 1992-94 by Stefan Stuntz");
  635.                     break;
  636.             }
  637.             if (running && signal) Wait(signal);
  638.         }
  639.     }
  640.  
  641.  
  642.  
  643. /*
  644. ** Call the fail function in demos.h, this will dispose the
  645. ** application object and close "muimaster.library".
  646. */
  647.  
  648.     fail(AP_Demo,NULL);
  649. }
  650.  
  651.  
  652. /*
  653. ** This is the end...
  654. */
  655.